$(function () {
    $('.input_sub').on('click', function () {
        // console.log(1)
        let username = $('.input_txt').val().trim()
        let password = $('.input_pass').val().trim()

        if (!username) alert('用户名不能为空')
        if (!password) alert('密码不能为空')
        console.log(username, password)

        $.ajax({
            type: 'post',
            url: 'http://localhost:8080/api/v1/admin/user/login',
            data: { username, password },
            dataType: 'json',
            success: function (res) {
                console.log(res)
                if (res.code === 200) {
                    // alert(res.msg)
                    $('.modal-body > p').text(res.msg)
                    localStorage.setItem('bignews_token', res.token)
                    $('#tipModal').on('hidden.bs.modal', function (e) {
                        location.href = './index.html'
                    })

                } else {
                    $('.modal-body > p').text(res.msg)
                    // alert(res.msg)
                }
                $('#tipModal').modal('show')
            }
        })

    })
})